package com.example.book.dao;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.book.entity.ShopCar;
import com.example.book.entity.vo.ShopCarVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * (ShopCar)表数据库访问层
 *
 * @author makejava
 * @since 2022-12-12 16:10:04
 */
@Mapper
public interface ShopCarDao extends BaseMapper<ShopCar> {

    /**
     * 多表查询   根据提供的对应对象进行对应的处理
     * @param ew
     * @param page
     * @return
     */
    @Select("<script>"+
            " SELECT s.*,b.book_name,b.book_image,b.price from shop_car s LEFT JOIN book b on b.id = s.book_id  "+
            "<where>${ew.sqlSegment}</where>"+
            "</script>")
    List<ShopCarVo>   getAllShopCarVo(@Param("ew") QueryWrapper ew, Page page);
}

